#include "stdafx.h"
#include "Fakes/FakeD3D11Device.h"
#include "Fakes/FakeD3D11Texture1D.h"

DESCRIPTION_11_TEST_SUITE_CTOR(Texture1DDescription, (DXGI_FORMAT_R8G8B8A8_UINT, 256))

BOOST_FIXTURE_TEST_CASE(Default, TestTexture1DDescription)
{
	BOOST_REQUIRE_EQUAL(DXGI_FORMAT_R8G8B8A8_UINT, m_desc.Format);
	BOOST_REQUIRE_EQUAL(256, m_desc.Width);
	BOOST_REQUIRE_EQUAL(1, m_desc.ArraySize);
	BOOST_REQUIRE_EQUAL(0, m_desc.MipLevels);
	BOOST_REQUIRE_EQUAL(D3D11_BIND_SHADER_RESOURCE, m_desc.BindFlags);
	BOOST_REQUIRE_EQUAL(D3D11_USAGE_DEFAULT, m_desc.Usage);
	BOOST_REQUIRE_EQUAL(0, m_desc.CPUAccessFlags);
	BOOST_REQUIRE_EQUAL(0, m_desc.MiscFlags);
}

#define TEXTURE1D_DESCRIPTION_TEST_CASE(type_, name_, value_) \
	DESCRIPTION_11_SETTER_TEST_CASE(type_, name_, value_, Texture1DDescription)

TEXTURE1D_DESCRIPTION_TEST_CASE(UINT, ArraySize, 2)
TEXTURE1D_DESCRIPTION_TEST_CASE(UINT, MipLevels, 2)
TEXTURE1D_DESCRIPTION_TEST_CASE(UINT, BindFlags, D3D11_BIND_STREAM_OUTPUT)
TEXTURE1D_DESCRIPTION_TEST_CASE(D3D11_USAGE, Usage, D3D11_USAGE_DYNAMIC)
TEXTURE1D_DESCRIPTION_TEST_CASE(UINT, CPUAccessFlags, D3D11_CPU_ACCESS_READ)
TEXTURE1D_DESCRIPTION_TEST_CASE(UINT, MiscFlags, D3D11_RESOURCE_MISC_SHARED)

BOOST_FIXTURE_TEST_CASE(CreateNoData, TestTexture1DDescription)
{
	FakeD3D11Device device;
	FakeD3D11Texture1D texture;
	device.CreateTexture1DFakeResult = &texture;
	device.CreateTexture1DFakeHResult = S_OK;
	ID3D11Texture1D *result = m_desc.Create(&device);
	BOOST_REQUIRE(device.CreateTexture1DCalled);
	BOOST_REQUIRE_EQUAL(&m_desc, device.CreateTexture1DLastDesc);
	BOOST_REQUIRE_EQUAL(static_cast<D3D11_SUBRESOURCE_DATA const *>(0), device.CreateTexture1DLastData);
	BOOST_REQUIRE_EQUAL(&texture, result);
}

BOOST_FIXTURE_TEST_CASE(CreateWithData, TestTexture1DDescription)
{
	FakeD3D11Device device;
	FakeD3D11Texture1D texture;
	device.CreateTexture1DFakeResult = &texture;
	device.CreateTexture1DFakeHResult = S_OK;
	int data = 1969;
	rt::D3D11::SubResourceData resource(&data);
	ID3D11Texture1D *result = m_desc.Create(&device, &resource);
	BOOST_REQUIRE(device.CreateTexture1DCalled);
	BOOST_REQUIRE_EQUAL(&m_desc, device.CreateTexture1DLastDesc);
	BOOST_REQUIRE_EQUAL(&resource, device.CreateTexture1DLastData);
	BOOST_REQUIRE_EQUAL(&texture, result);
}

BOOST_AUTO_TEST_SUITE_END()
